package Modele;

public class Position implements Comparable, java.io.Serializable{

	private int x;
	private int y;
	
	public Position(Position _p)
	{
		this(_p.x,_p.y);
	}
	public Position(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	public void setXY(int x, int y)
	{
		this.x=x;
		this.y=y;
	}
	@Override
	public int compareTo(Object arg0) {
		if(arg0 instanceof Position)
		{
			Position p = (Position) arg0;
			if(p.x ==this.x && p.y ==this.y)
				return 0;
			else return 1;
		}
		return 1;
	}
	
	@Override
	public boolean equals (Object obj)
	{
        if (obj!= null && (obj.getClass().equals(this.getClass())))
        {
            if (obj instanceof Position)
            {
                Position pos = (Position)obj;
                return (this.x == pos.x && this.y == pos.y);
            }
            else return false;
	    }
        return false;
	}
	
	@Override
	public int hashCode(){
	    return this.x*10000+this.y;
	}   
	
	
	public String toString()
	{
		return x+ " : " +y;
	}
	
}
